<template>
  <div style="width:100%;height:100%;">
    <slider ref="slider" :options="options" @slide="slide" @tap="onTap" @init="onInit">
      

      <slideritem :style="{ background: '#fff'}">
        <!-- <div class="a"></div> -->
         <el-image src="/static/img/xmzs/17项目.jpg" fit="fit" style="position:relative;height:100%;width:100%" />
      </slideritem>

      <slideritem :style="{ background: '#fff' }">
        <el-image src="/static/img/xmzs/17项目2.jpg" fit="fit" style="position:relative;height:100%;width:100%" />
      </slideritem>
      <!-- 示范河湖项目1 -->
      <slideritem :style="{ background: '#fff' }">
        <el-image src="/static/img/xmzs/17项目3.jpg" fit="fit" style="position:relative;height:100%;width:100%" />
      </slideritem>
      <slideritem :style="{ background: '#fff' }">
        <el-button type="primary">4</el-button>
      </slideritem>
      <div slot="loading">loading...</div>
    </slider>
  </div>
</template>

<script>
import { slider, slideritem } from 'vue-concise-slider' // import slider components
export default {

  components: {
    slider,
    slideritem
  },
  data() {
    return {
      startTime: 0,
      endTime: 0,
      options: {
        currentPage: 0,
        thresholdDistance: 500,
        thresholdTime: 100,
        //autoplay: 1000,
        loop: true,
        direction: 'vertical',
        loopedSlides: 1,
        slidesToScroll: 1,
        timingFunction: 'ease',
        // renderPagination: (h, index) => {
        //   console.log(index)
        //   return h(
        //     'div',
        //     {
        //       class: 'swiper-pagination-bullet'
        //     },
        //     []
        //   )
        // },
        // pagination: true,
         speed: 800
      }
    }
  },
  mounted() {
    window.onmousewheel = this.srollWheel
  },
  methods: {
    // 鼠标滚动
    srollWheel(event) {
      this.startTime = new Date().getTime()
      // mousewheel事件中的 “event.wheelDelta” 属性值：返回的如果是正值说明滚轮是向上滚动
      // DOMMouseScroll事件中的 “event.detail” 属性值：返回的如果是负值说明滚轮是向上滚动
      const delta = event.deltaY
      // 如果当前滚动开始时间和上次滚动结束时间的差值小于1.5s，则不执行翻页动作，这样做是为了实现类似节流的效果
      if (this.startTime - this.endTime > 500) {
        if (delta > 0) {
          // 向下滚动
          this.$refs['slider'].next()
        } else {
          // 向上滚动
          this.$refs['slider'].pre()
        }
        // 本次翻页结束，记录结束时间，用于下次判断
        this.endTime = new Date().getTime()
      }
    },
    // Listener event
    slide(data) {
      console.log(data)
    },
    onTap(data) {
      console.log(data)
    },
    onInit(data) {
      console.log(data)
    }
  }
}
</script>

<style scoped>
.swiper-pagination-bullet {
  width: 15px;
  height: 15px;
  background-color: wheat;
  border-radius: 50%;
  -moz-border-radius: 50%;
  -webkit-border-radius: 50%;
  margin-bottom: 5px;
  cursor: pointer;
}

.container {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
}

.a{
  position: relative;
  height: 100%;
  left: 0;
  right: 0;
  bottom: 0;
  top: 0;
  width: 100%;
  background-image: url(../../assets/img/xmzs/17项目.jpg);
}
</style>
